package com.example.microinvestcommon.util;

import org.springframework.stereotype.Component;

@Component
public class SendMailUtil {

    public Boolean sendEmail(String userEmail,String code) {


        try {
            String emailContent = "<html>" +
                    "<body style='font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f4;'>" +
                    "<div style='max-width: 600px; margin: 0 auto; background-color: #ffffff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);'>" +
                    "<h2 style='color: #333333;'>你好，欢迎使用 Microinvest！</h2>" +
                    "<p style='font-size: 16px; color: #555555;'>你的验证码为：<strong style='color: #0066cc;'>" + code + "</strong></p>" +
                    "<p style='font-size: 14px; color: #888888;'>验证码有效期为 5 分钟，请及时使用。</p>" +
                    "<p style='font-size: 14px; color: #888888;'>如果你没有进行此操作，请忽略此邮件。</p>" +
                    "<hr style='border-top: 1px solid #eeeeee;'/>" +
                    "<footer style='font-size: 12px; color: #888888; text-align: center;'>" +
                    "<p>Microinvest团队 &copy; 2025</p>" +
                    "</footer>" +
                    "</div>" +
                    "</body>" +
                    "</html>";

            MailVerificationUtil.sendMail(userEmail, "Microinvest - 验证码", emailContent, null, null);

        } catch (Exception e) {
            return false;
        }
        return true;
    }
}
